<?php

namespace admin\models;

use Yii;

/**
 * This is the model class for table "mm_user_health".
 *
 * @property integer $mh_id
 * @property integer $mu_id
 * @property string $mh_state
 * @property string $mh_history
 * @property string $mh_syntrophus
 *
 * @property Info $mu
 */
class UserHealth extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'mm_user_health';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['mu_id'], 'integer'],
            [['mh_state','mh_history','mh_syntrophus'],'required'],
            [['mh_state', 'mh_history', 'mh_syntrophus'], 'string'],
            [['mu_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserInfo::className(), 'targetAttribute' => ['mu_id' => 'mi_id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'mh_id' => '健康状态id',
            'mu_id' => '用户id',
            'mh_state' => '健康状态',
            'mh_history' => '有无病史',
            'mh_syntrophus' => '有无遗传病',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getMu()
    {
        return $this->hasOne(UserInfo::className(), ['mi_id' => 'mu_id']);
    }
}
